﻿using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices;

namespace ZhuXingFamilys
{
    class ApplicationAvailabilityClass : IExternalCommandAvailability
    {
        public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
        {
            Application revitApplication = applicationData.Application;
            ApplicationOptions options = ApplicationOptions.Get();

            switch (options.Availability)
            {
                case ApplicationAvailablity.ArchitectureDiscipline:
                    return revitApplication.IsArchitectureEnabled;

                case ApplicationAvailablity.StructuralAnalysis:
                    return revitApplication.IsStructuralAnalysisEnabled;

                case ApplicationAvailablity.MEP:
                    return revitApplication.IsSystemsEnabled;
            }
            return true;
        }
    }
}
